﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsForm
{
    public partial class Form1 : Form
    {
        /// <summary>
        /// 标识是否第一次“非常帅”按钮
        /// </summary>
        private static int mark = 0;
        public Form1()
        {
            InitializeComponent();
            // 禁用最大化和最小化按钮
            this.MaximizeBox = false;
            this.MinimizeBox = false;

            //没有简单的MessageBox.Show居中方法，只好让窗体在Windows桌面居中显示
            this.StartPosition = FormStartPosition.CenterScreen;

            //设置按钮层级为最顶层，不让其他控件覆盖到它
            button2.BringToFront();

            //设置控件层级
            //this.Controls.SetChildIndex(button1, 10);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 鼠标进入事件
        /// </summary>
        private void button2_MouseEnter(object sender, EventArgs e)
        {
            var ls = new List<string> { "从了我吧", "碰不到我吧", "好好想想", "点不到我的，放弃吧", "啦啦啦啦啦", "略略略略略略", "去点另一个吧", "听从内心吧" };
            button2.Text = ls[new Random().Next(8)];
            var rd = new Random();
            var btn = sender as Button;
            var maxW = this.Width;
            var maxH = this.Height;
            var w = btn.Width;
            var h = btn.Height;
            var l = rd.Next(0, maxW - w);
            var t = rd.Next(0, maxH - h);
            btn.Left = l;
            btn.Top = t;

            //设置按钮颜色
            var colors = new List<Color> { Color.BlueViolet, Color.Black, Color.Blue, Color.Violet, Color.Chartreuse };
            btn.ForeColor = colors[new Random().Next(5)];

            //设置按钮背景颜色
            var bcolors = new List<Color> { Color.Black, Color.WhiteSmoke, Color.Aqua, Color.CadetBlue, Color.Yellow };
            btn.BackColor = bcolors[new Random().Next(5)];

            var picList = new List<PictureBox> { pictureBox1, pictureBox2, pictureBox3, pictureBox4, pictureBox5 };

            var cuteStr = new List<string>{ "这是我媳妇儿" ,"好漂亮啊", "我媳妇就是好看", "那么可爱" ,"哇哦哇哦哇哦", "美女哦" };
            var randNum = new Random().Next(5);
            for (var i = 0; i < 5; i++)
            {
                if (i == randNum)
                {
                    foreach (var box in picList)
                    {
                        box.Visible = false;
                    }
                    picList[i].Visible = true;
                    if (i > 0)
                    {
                        label1.Text = cuteStr[new Random().Next(6)];
                    }
                    else
                    {
                        label1.Text = "小妹妹，哥哥帅不帅";
                    }
                }
            }

            mark++;
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            MessageBox.Show("          关不掉我的！略略略！");//增加空格是为了居中显示
            e.Cancel = true;
        }

        /// <summary>
        /// 控制按钮显示隐藏事件
        /// </summary>
        private void button1_Click(object sender, EventArgs e)
        {
            if (mark == 0)
            {
                MessageBox.Show("            第一次就选我，哈哈哈哈，开心");
                mark++;
            }
            button1.Visible = false;
            button2.Visible = false;
            button3.Visible = true;
            label1.Text = "小妹妹眼光不错";
        }

        /// <summary>
        /// 关闭按钮事件
        /// </summary>
        private void button3_Click(object sender, EventArgs e)
        {
            MessageBox.Show("          想我的时候可以再打开哦！");
            Environment.Exit(0);
        }
    }
}
